﻿@namespace BootstrapBlazor.Components
@typeparam TModel
@inherits BootstrapComponentBase

<CascadingValue Value="@EditorItems" IsFixed="true">
    @FieldItems?.Invoke(Model)
</CascadingValue>

@if (FirstRender)
{
    <div class="ef-loading">
        <Spinner Color="Color.Primary" />
    </div>
}
else
{
    <div class="@FormClassString">
        <CascadingValue Value="this" Name="EidtorForm">
            @foreach (var item in FormItems)
            {
                var render = GetRenderTemplate(item);
                @if (render != null)
                {
                    @render(Model)
                }
                else
                {
                    <div class="@GetCssString(item)">
                        @AutoGenerateTemplate(item)
                    </div>
                }
            }
        </CascadingValue>
        @if (Buttons != null)
        {
            <div class="col-12">
                @Buttons
            </div>
        }
    </div>
}
